import {common, http} from 'src/service/common'

export default {

  /**
   * 不模拟登录了
   * @returns {Promise<*>}
   */
  unmocklogin: async function () {
    return common.datas(await  http.get('/api/user/unmocklogin'))
  },
  customerList: async function (data) {
    return common.datas(await  http.post('/api/customer/search', data))
  },
  customer: async function (id) {
    return common.datas(await http.get('/api/customer/' + id))
  },
  /**
   * 可售商品查询
   * @param data
   * @returns {Promise<*>}
   */
  sellSearch: async function (data) {
    return common.datas(await  http.post('/api/sells/search', data))
  },
  changePassword: async function (data) {
    return common.datas(await  http.post("/api/user/changepassword", data))
  },
  /**
   * 查询地域的子节点数据
   * @param id
   * @returns {Promise<*>}
   */
  districts: async function (id) {
    return common.datas(await http.get('/api/district/children/' + id))
  },
  districtTree: async function (id) {
    return common.datas(await  http.get('/api/district/tree/' + id))
  },
  systemConfig: async function () {
    return common.datas(await http.get('/api/system/config'))
  },
  userRegister: async function (data) {
    return common.datas(await  http.post('/api/user/register', data))
  },
  login: async function (data) {
    return common.datas(await http.post('/api/user/login', data))
  },
  userInfo: async function () {
    return common.datas(await http.get('/api/user/info'))
  },
  auths: async function () {
    return common.datas(await http.get("/api/public/auths"));
  },
  qqLogin: async function () {
    return common.datas(await http.get('/api/public/qq/login'))
  },
  bindInfo: async function () {
    return common.datas(await http.get('/api/user/bindInfo'))
  },
  //获取消费信息
  userDeposit: async function () {
    return common.datas(await http.get('/api/user/deposit'))
  },
  bindNew: async function (data) {
    return common.datas(await http.post('/api/user/bind/new', data))
  },
  bindExist: async function (data) {
    return common.datas(await http.post('/api/user/bind/exist', data))
  },
  //订单查询
  orderSearch: async function (data) {
    return common.datas(await http.post('/api/orders/search', data))
  },
  //删除订单信息
  deleteOrder: async function (id) {
    return common.datas(await http.delete('/api/orders/' + id))
  },
  userAddresses: async function () {
    return common.datas(await http.get('/api/user/addresses'))
  },
  addUserAddress: async function (data) {
    return common.datas(await http.post('/api/user/address', data))
  },
  //删除地址
  deleteAddress: async function (id) {
    return common.datas(await http.delete('/api/user/address/' + id))
  },
  //更新默认地址
  defaultAddress: async function (id) {
    return common.datas(await http.put('/api/user/address/default/' + id))
  },
  //发货申请
  ordersApply: async function (data) {
    return common.datas(await  http.post('/api/orders/apply', data))
  },
  deliveries: async function (data) {
    return common.datas(await http.post('/api/delivery/search', data))
  },
  deliveryOrder: async function () {
    return common.datas(await http.get('/api/delivery/order'))
  },
  //获取快递列表
  expresses: async function () {
    const data = {
      isShow: 1
    }
    return common.datas(await http.post('/api/express/search', data))
  },
  expressLog: async function (code, post) {
    return common.datas(await http.get('/api/express/' + code + '/' + post))
  },
  qqAuth: async function () {
    return common.datas(await http.get('/api/public/qqAuth'))
  },
  wxAuth: async function () {
    return common.datas(await http.get('/api/public/wxAuth'))
  },
  webInfo: async function () {
    return common.datas(await http.get('/api/public/site/info'))
  },
  //订单改名
  orderRename: async function (data) {
    return common.datas(await  http.post('/api/rename', data))
  },
  orderUnRename: async function (data) {
    return common.datas(await  http.post('/api/unrename', data))
  },
  //更名订单查询
  renameSearch: async function (data) {
    return common.datas(await http.post('/api/rename/search', data))
  },
  refund: async function (data) {
    return common.datas(await http.post('/api/refund', data))
  },
  //创建订单
  orderCreate: async function (data) {
    return common.datas(await http.post('/api/orders/create', data))
  }
}
